package com.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bean.Complex;
import com.bean.Unit;
import com.service.ComplexService;
import com.service.UnitService;
@Controller
public class AjaxAction {
	
	@Autowired
	private ComplexService complexService;
	
	
	//id返回map
	@RequestMapping("toAjax.do")
	public @ResponseBody Map<String, Object> toAjax(Integer  id){
		
    //项目id查询Complex楼栋list
	List<Complex> complexList=complexService.selectByProjectId(id);

	//complexList放到map中
	Map<String, Object> map = new HashMap<String, Object>();
	map.put("complexList", complexList);
	return map;
	}
	
	
	@Autowired
	private UnitService unitService;
	
	
	//id返回map
	@RequestMapping("toAjax2.do")
	public @ResponseBody Map<String, Object> toAjax2(Integer  id){
		
    //项目id查询Complex楼栋list
	List<Unit> unitList=unitService.selectByComplexId(id);

	//complexList放到map中
	Map<String, Object> map = new HashMap<String, Object>();
	map.put("unitList", unitList);
	return map;
	}

}
